package com.arvts.android.project.data;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {

	// database information
	public static final String DATABASE_NAME = "database.db";
	public static final int DATABASE_VERSION = 1;
	
	public DatabaseHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	/**
	 * ############################ server table Details #################################
	 */
	// table
	public static final String TABLE_VEHICLE = "vehicle_tbl";
	// table attributes
	public static final String VEHICLE_ID = "id";
	public static final String VEHICLE_SERVICE_DURATION = "service_duration";
	public static final String VEHICLE_IDLE_TIME_LIMIT = "idle_time_limit";
	public static final String VEHICLE_NUMBER = "vehicle_number";
	public static final String VEHICLE_DEVICE_PASSWORD = "device_password";
	public static final String VEHICLE_TYPE = "vehicle_type";
	public static final String VEHICLE_LOCK_STATUS = "lock_status";
	public static final String VEHICLE_LOCKED_DATE = "locked_date";
	public static final String VEHICLE_DATE_CREATED = "date_created";
	public static final String VEHICLE_SECONDARY_PHONE_NUMBER = "secondary_phone_numbers";
	public static final String VEHICLE_SERVICE_MILEAGE = "service_mileage";
	public static final String VEHICLE_INITIAL_MILEAGE_READING = "initial_mileage_reading";
	public static final String VEHICLE_DEVICE_PHONE_NUMBER = "device_phone_number";
	
	
	private static final String CREATE_VEHICLE_TABLE = "CREATE TABLE IF NOT EXISTS "
			+ TABLE_VEHICLE + " (" 
			+ VEHICLE_ID+ " TEXT,"
			+ VEHICLE_SERVICE_DURATION+ " TEXT,"
			+ VEHICLE_IDLE_TIME_LIMIT+ " TEXT,"
			+ VEHICLE_NUMBER+ " TEXT,"
			+ VEHICLE_DEVICE_PASSWORD+ " TEXT,"
			+ VEHICLE_TYPE+ " TEXT,"
			+ VEHICLE_LOCK_STATUS+ " TEXT,"
			+ VEHICLE_LOCKED_DATE+ " TEXT,"
			+ VEHICLE_DATE_CREATED+ " TEXT,"
			+ VEHICLE_SECONDARY_PHONE_NUMBER+ " TEXT,"
			+ VEHICLE_SERVICE_MILEAGE+ " TEXT,"
			+ VEHICLE_INITIAL_MILEAGE_READING+ " TEXT,"
			+ VEHICLE_DEVICE_PHONE_NUMBER+ " TEXT); ";

	
	
	@Override
	public void onCreate(SQLiteDatabase arg0) {
		
		arg0.execSQL(CREATE_VEHICLE_TABLE);
		
	}
	
	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
		
		this.onCreate(arg0);

	}
}
